from fastapi import APIRouter, Depends
from fastapi.security import OAuth2PasswordRequestForm
from sqlalchemy.orm import Session

from common.config.database import get_db
from app.admin_service.schemas.session import SessionResponse
from app.admin_service.service import session_service

router = APIRouter(
    prefix="/session",
    tags=["会话"],
    responses={404: {"description": "Not found"}}
)


@router.post("", summary="创建会话", response_model=SessionResponse)
def create(form_data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
    return session_service.create(db, form_data.username, form_data.password)
